<?php

	include("includes/connect.php");

?>

<script type="text/javascript">
	$(document).ready(function(){
		$("a[id^='edit']").click(function() {
			
			event.preventDefault();

			$('<div>').dialog2({
				autoOpen: true,
				title: "บันทึกข้อมูล",
				content: "modal_test.php",
				id: "modal-menus-edit"
			});

		});

		$('#example').dataTable({
			"sDom": "<'row-fluid'<'span6'T><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
			"oTableTools": {
			"aButtons": [
				"copy",
				"print",
				{
					"sExtends":    "collection",
					"sButtonText": 'Export <span class="caret" />',
					"aButtons":    [ "csv", "xls", "pdf" ]
				}
			]
		}
		});


				$("li").find("span.editm").hide();

				$("tr").hover(
						function() {
							$(this).find("span.editm:first").show();
						},
						function() {
							$(this).find("span.editm:last").hide();
						}
				);

				//li with fade class
				$("li.fade").hover(function() {
					$(this).fadeOut(100);
					$(this).fadeIn(500);
				});        
	});
</script>

<button class="btn btn-primary">เพิ่มข้อมูล</button>
<div id="ikob">
	<table id="example" class="table table-bordered" width="100%" >
		<caption><br></caption>
		<thead>
			<tr>
				<th>#</th>
				<th>ชื่อ - นามสกุล</th>
				<th>อายุ</th>
				<th>action</th>
			</tr>
		</thead>
		<tbody>
		<?php
			$sql = "SELECT * FROM tblTest";
			$query = mysql_query( $sql );
			$array = array();
			while ($row1 = mysql_fetch_object( $query )) {
				$array[] = $row1;
			}
			$rows = $array;
			for ($i=0, $n=count( $rows ); $i < $n; $i++) {
				$row = &$rows[$i];
		?>
							
			<tr>
			  <td><?php echo $row->id; ?></td>
			  <td><?php echo $row->name; ?></td>
			  <td><?php echo $row->age; ?></td>
			  <td>
			  <a href="#" id="edit<?php echo $row->id; ?>"><i class="icon-edit"></i>แก้ไข</a> / <a href="#" id="del<?php echo $row->id; ?>"><i class="icon-trash"></i>ลบ</a>

					<span class="editm dropdown " style="display: none;">
                        <a class=" dropdown-toggle" data-toggle="dropdown" href="#"><i class="icon-pencil"></i></a>
                        <ul class="dropdown-menu">
                            <li><a href="#" id="submenus29"><i class="icon-pencil"></i> แก้ไข</a></li>
                            <li><a href="#" id="delMenu29"><i class="icon-trash"></i> ลบ</a></li>
                            <li><a href="#" id="upMenu29"><i class="icon-arrow-up"></i> เลื่อนขึ้น</a></li>
                            <li><a href="#" id="dnMenu29"><i class="icon-arrow-down"></i> เลื่อนลง</a></li>
                        </ul>
                    </span>

			  </td>
					
			</tr>
			
		<?php } ?>
		</tbody>

	</table>

	
</div>

